import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GraphInfo extends JPanel implements ActionListener {

  JLabel sine = new JLabel("Sine"), cosine = new JLabel("Cosine"),
         tangent = new JLabel("Tangent");

  JTextField sinText = new JTextField(5), cosText = new JTextField(5),
             tanText = new JTextField(5);

  JButton graph = new JButton("Graph");
  Graph plotted;


  public GraphInfo(Graph plotted) {
    this.plotted = plotted;
    this.setLayout(new FlowLayout());
    this.add(sine);
    this.add(sinText);
    this.add(cosine);
    this.add(cosText);
    this.add(tangent);
    this.add(tanText);
    this.add(graph);


    graph.addActionListener(this);
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == graph) {
      if (!sinText.getText().equalsIgnoreCase("")) {
        String[] temp = sinText.getText().split("");

        plotted.setCounter(1);
        plotted.setValue(Integer.parseInt(temp[1]));
        plotted.drawGraph();

      }
    }
  }

}
